package com.example.mybatis.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.example.mybatis.entity.Enum.UserSexEnum;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/**
 * @author Devil
 * @create 2022-03-04 15:10
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    /**
     * 在这里配置insert时填充的字段
     * @param metaObject
     */
    @Override
    public void insertFill(MetaObject metaObject) {
        setFieldValByName("sex", UserSexEnum.MAN,metaObject);
    }

    /**
     * 这里配置update时填充的字段
     * @param metaObject
     */
    @Override
    public void updateFill(MetaObject metaObject) {

    }
}
